package com.xuetang9.t9.xinhuaxia.controller;

import com.github.pagehelper.PageInfo;
import com.xuetang9.t9.xinhuaxia.beans.FirstCategory;
import com.xuetang9.t9.xinhuaxia.beans.Goods;
import com.xuetang9.t9.xinhuaxia.beans.Orderlist;
import com.xuetang9.t9.xinhuaxia.service.IOrderlistService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 李亚奇
 * @version 1.0
 * @desc TODO
 * @date 2020/3/4 14:51
 * @copyright liyq
 * @address 成都西部国际金融中心2栋2201
 **/
@RestController
@RequestMapping("orderlist")
public class OrderListController {
    @Autowired
    private IOrderlistService orderlistService;

    @PostMapping("save")
    public boolean insert(@RequestBody Orderlist orderlist){
        boolean insert = orderlistService.insert(orderlist);
        return insert;
    }

    @GetMapping("remove/{id}")
    public boolean remove(@PathVariable(value = "id",required = false) Long id){
        boolean remove = orderlistService.remove(id);
        return remove;
    }

    @GetMapping("queryByOrderId/{id}")
    public List<Orderlist> queryByOrderId(@PathVariable(value = "id",required = false) Long id){
        List<Orderlist> orderlists = orderlistService.queryByOrderId(id);
        return orderlists;
    }

    @PostMapping("update")
    public boolean update(@RequestBody Orderlist orderlist){
        boolean update = orderlistService.update(orderlist);
        return update;
    }

    @GetMapping("list/{page}/{perPagesize}")
    public PageInfo<Orderlist> queryByPage(@PathVariable(value = "page",required = false) Integer page, @PathVariable(value = "perPagesize",required = false) Integer perPagesize){
        PageInfo<Orderlist> pageInfo = orderlistService.queryByPage(page, perPagesize);
        return pageInfo;
    }


}
